import { lazy} from "react";
import { useRoutes } from 'react-router';
import type { IRouter } from '@/types/router';
import { techShare } from './modules/teachShare';
import { originalTech } from './modules/originalTech';
import { course } from './modules/course';

const routes: IRouter[] = [
  {
    path: '/',
    Component: lazy(() => import('@/pages/Home')),
    meta: {
      title: '首页',
      hidden: false
    }
  },
  {
    path: '/search',
    Component: lazy(() => import('@/pages/SearchResult')),
    meta: {
      title: '搜索结果',
      hidden: true
    }
  },
  {
    path: '/article/:id',
    Component:
    
    lazy(() => import('@/pages/CurrentArticle')),
    meta: {
      title: '文章详情',
      hidden: true
    }
  },
  // 配置重定向
  {
    path: '*',
    redirect: '/404',
    Component: lazy(() => import('@/pages/NotFound')),
    meta: {
      title: '404',
      hidden: true
    }
  }
];

export const allRoutes = [...routes, ...originalTech, ...techShare, ...course];

// 使用useRoutes 返回路由 用于在 App.tsx 中使用
export const useAppRoutes = () => {
  return useRoutes(allRoutes);
};

export default allRoutes;
